import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/page/Home'

// 登录页面
const Home = r => require.ensure([], () => r(require('@/components/page/Home')), 'Home')

Vue.use(Router)

const router = new Router({
  base: '/',
  mode: 'history',
  routes: [
    {
      path: '/',
      redirect: '/home'
    },
    {
      path: '/home',
      component: Home,
      meta: {title: '自述文件'},
      children: [
        {
          path: '/home',
          meta: {title: '首页', type: '首页'},
          name: 'Login',
          component: Home
        }
      ]
    }
  ]
})

router.beforeEach((to, from, next) => {
  /* 路由发生变化修改页面title */
  if (to.meta.title) {
    window.document.title = to.meta.title
  }
  next()
})

export default router
